<?php
     // set maximum execution time go non stop
    set_time_limit(0);
    
    //start zipping the files
    $date = date("Y-m-d");
    
    
    // Include the PclZip library
    require_once('pclzip.lib.php');

    // Set the arhive filename
    $arcname = "backup/T&D_inmobiliaria_".$date.".zip";
    
    $archive = new PclZip($arcname);

    // Set the dir to archive
    $v_dir = dirname(__FILE__);
    $v_remove = $v_dir;

    // Create the archive
    $v_list = $archive->create($v_dir, PCLZIP_OPT_REMOVE_PATH, $v_remove);
    if ($v_list == 0) {
        die("Error : ".$archive->errorInfo(true));
    }
	if (file_exists($arcname)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($arcname));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($arcname));
    ob_clean();
    flush();
    readfile($arcname);
    exit;
}